#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int n,l,r,ans,p;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l+1>=n) cout<<n-1;
	else
	{
		for(int i=l;i<=r;i++)
			ans=max(ans,i%n);
		cout<<ans;
	}
	return 0;
}
